package easy.netty.net.core;

import java.util.Objects;
import java.util.UUID;

/**
 * @author cengy
 */
public class Component {

    protected Entity entity;
    protected String id;
    public Component(Entity entity) {
        this.entity = entity;
        this.id = UUID.randomUUID().toString();
    }

    public Entity getEntity() {
        return entity;
    }

    public void setEntity(Entity entity) {
        this.entity = entity;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void init() {

    }

    public void afterInit() {

    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Component component = (Component) o;
        return Objects.equals(id, component.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
